import pagination from '@/views/pagination'  //分页组件
import dialogForm from './edit'
import agentHttp from '@/utils/agentHttp.js'
import {confirm} from '@/utils/confirm'      //二次确认组件
export default {
  name: 'hotBrands',
  created(){
      this.seachData(this.searchForm)
  },
  components:{dialogForm,pagination},
  data() {
  	return {
  		tableData: [],
      searchForm:{},
      formLabelWidth:'120px',
      //弹窗状态数据
      dialogSendData:{
        isAdd:"",
        dialogFormVisible:"",
        id:""
      }
  	}
  },
  methods: {
    seachData(){
      var params=this.searchForm||{};
      params.page=this.tableData.page||1;
      params.rows=this.tableData.rows||10;
      agentHttp.postJson('adminApi/admin/car_hot_brand/queryAllByEntity?page='+params.page+'&rows='+params.rows,params ).then((data)=>{
            this.tableData = data
      })
    },
    /*表格操作按钮*/
    //查看
    handleSee(index, row){
      this.dialogSendData.isAdd=false;
      this.dialogSendData.id=row.id;
      this.dialogSendData.dialogFormVisible=true;
    },
    //编辑/审核
    handleEdit(index, row) {
      row?this.dialogSendData.id=row.id:this.dialogSendData.id="";
      this.dialogSendData.isAdd=true;
      this.dialogSendData.dialogFormVisible=true;
    },
    //删除
    handleDel(index, row){
        confirm(()=>{
          agentHttp.del('adminApi/admin/car_hot_brand/'+row.id).then((data)=>{
            if(data.success){  
                this.$message.success(data.data||"删除成功");
                this.seachData({});
                //这里编写数据赋值或者其他逻辑  例如：this.tableData = data;
            } 
          })
        },()=>{
           this.$message.info('已取消删除'); 
        },"确认删除该条数据吗?")
    }
  }
}